home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
util
/
vec.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
4KB
|
104 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from __future__ import division
from itertools import izip
import math
class vector(list):
def __init__(self, *a):
if len(a) == 1:
list.__init__(self, *a)
else:
list.__init__(self, iter(a))
def __getslice__(self, i, j):
return vector(list.__getslice__(i, j))
def __add__(self, v):
return vector((lambda .0: for x, y in .0:
x + y)(izip(self, v)))
def __neg__(self):
return vector((lambda .0: for x in .0:
-x)(self))
def __sub__(self, v):
return vector((lambda .0: for x, y in .0:
x - y)(izip(self, v)))
def __mul__(self, o):
try:
iter(o)
except:
return (vector,)((lambda .0: for x in .0:
x * o)(self))
return vector((lambda .0: for x, y in .0:
x * y)(izip(o)))
def div(self, o):
try:
iter(o)
except:
return (vector,)((lambda .0: for x in .0:
x / o)(self))
return vector((lambda .0: for x, y in .0:
x * y)(izip(o)))
def __repr__(self):
return 'vec' + repr(tuple(self))
def distance(cls, v1, v2):
return sum((lambda .0: for x, y in .0:
(y - x) ** 2)(izip(v1, v2))) ** 0.5
distance = classmethod(distance)
def to(self, other):
return vector.distance(self, other)
def length(self):
return vector.distance(self, (0,) * len(self))
length = property(length)
def normal(self):
try:
return self.div(self.length)
except ZeroDivisionError:
return vector((0,) * len(self))
normal = property(normal)
def zero(n = 2):
return vector((0,) * n)
zero = staticmethod(zero)
def angle(self):
try:
return abs(math.atan(self[1] / self[0]) * 180 / math.pi)
except ZeroDivisionError:
return 90
angle = property(angle)